import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    component: () => import('@/views/Layout'),
    children: [
      {
        path: '/',
        component: () => import('@/views/Home')
      },
      {
        path: '/category/:id',
        component: () => import('@/views/Category')
      },
      {
        path: '/category/sub/:id',
        component: () => import('@/views/Category/sub.vue')
      },
      {
        path: '/good/:id',
        component: () => import('@/views/Goods')
      },
      {
        path: '/cart',
        component: () => import('@/views/Cart')
      },
      {
        path: '/order',
        component: () => import('@/views/Member/order')
      },
      {
        path: '/settlement',
        component: () => import('@/views/Member/settlement/index.vue')
      },
      {
        path: '/pay',
        component: () => import('@/views/Member/pay/index.vue')
      },
      {
        path: '/pay/callback',
        component: () => import('@/views/Member/pay/result.vue')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/Login')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  // Vue2: {x:0, y:0} Vue3: {left:0, top:0}
  scrollBehavior: () => ({ left: 0, top: 0 })
})

export default router
